# # -*- coding: utf-8 -*-
# # **********************************************************
# # * Author        : 赵刚
# # * Create time   : 2021/12/14 9:43
# # * Description   :
# # **********************************************************
# import traceback
#
# from redis import ConnectionPool, Redis
# from redis.exceptions import TimeoutError
#
# from settings import REDIS_CONFIG, REDIS_RETRY_TIMES
#
#
# class RedisQueue:
#     @staticmethod
#     def get_redis_conn():
#         """获取redis连接"""
#         for _ in range(REDIS_RETRY_TIMES):
#             try:
#                 pool = ConnectionPool(**REDIS_CONFIG)
#                 redis = Redis(connection_pool=pool)
#                 redis.ping()
#             except TimeoutError:
#                 if _ < REDIS_RETRY_TIMES - 1:
#                     continue
#                 raise traceback.format_exc()
#             else:
#                 return redis
#
#     @classmethod
#     def push_task(cls, channel, data):
#         """任务发放"""
#         return cls.get_redis_conn().lpush(channel, data)
